package com.lingz.manager.modules.wuxue.controller;

import com.lingz.manager.base.DevplatBaseController;
import com.lingz.manager.base.DevplatBaseDao;
import com.lingz.manager.common.utils.ResultUtil;
import com.lingz.manager.common.vo.Result;
import com.lingz.manager.modules.wuxue.entity.DeviceInfo;
import com.lingz.manager.modules.wuxue.entity.OpeEntInfo;
import com.lingz.manager.modules.wuxue.service.DeviceInfoService;
import com.lingz.manager.modules.wuxue.service.OpeEntInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(description = "武穴经营主体管理接口")
@RequestMapping("/wuxue/opeentity")
@Transactional
public class OpeEntInfoController extends DevplatBaseController<OpeEntInfo,String> {
    @Autowired
    OpeEntInfoService opeEntInfoService;

    @Override
    public OpeEntInfoService getService(){return opeEntInfoService;}

    @GetMapping("/findOpeEntInfoById")
    @ApiOperation("根据id获取主体信息")
    public Result<OpeEntInfo> findOpeEntInfoById(int id){
        return new ResultUtil<OpeEntInfo>().setData(opeEntInfoService.findOpeEntInfoById(id));
    }

    @GetMapping("/findOpeEntInfoByType")
    @ApiOperation("根据type获取主体信息")
    public Result<List<OpeEntInfo>> findOpeEntInfoByType(@RequestParam("type") String entityType){
        return new ResultUtil<List<OpeEntInfo>>().setData(opeEntInfoService.findOpeEntInfoByType(entityType));
    }

    @GetMapping(value = "/findOpeEntInfoList")
    @ApiOperation(value = "不分页查询主体信息")
    public Result<List<OpeEntInfo>> findOpeEntInfoList(OpeEntInfo opeEntInfo){
        return new ResultUtil<List<OpeEntInfo>>().setData(opeEntInfoService.findListOpeEntInfo(opeEntInfo));
    }
    @GetMapping(value = "/findOpeEntInfoNumByType")
    @ApiOperation(value = "根据实体类型查询主体数量")
    public Result<Integer> findOpeEntInfoNumByType(@RequestParam("type") String entityType, @RequestParam(value = "city",required = false) String cityName,@RequestParam(value = "town",required = false) String townName,@RequestParam(value = "village",required = false) String villageName){
        return new ResultUtil<Integer>().setData(opeEntInfoService.findOpeEntInfoNumByType(entityType,cityName,townName,villageName));
    }
    @GetMapping(value = "/findOpeEntInfoNumByInd")
    @ApiOperation(value = "根据产业类型查询主体数量")
    public Result<Integer> findOpeEntInfoNumByInd(@RequestParam("industry") String industry, @RequestParam(value = "city",required = false) String cityName,@RequestParam(value = "town",required = false) String townName,@RequestParam(value = "village",required = false) String villageName){
        return new ResultUtil<Integer>().setData(opeEntInfoService.findOpeEntInfoNumByInd(industry,cityName,townName,villageName));
    }
    @GetMapping(value = "/findOpeEntInfoNumByBus")
    @ApiOperation(value = "根据服务类型查询主体数量")
    public Result<Integer> findOpeEntInfoNumByBus(@RequestParam("business") String business, @RequestParam(value = "city",required = false) String cityName,@RequestParam(value = "town",required = false) String townName,@RequestParam(value = "village",required = false) String villageName){
        return new ResultUtil<Integer>().setData(opeEntInfoService.findOpeEntInfoNumByBus(business,cityName,townName,villageName));
    }
}
